<!DOCTYPE html>


<html lang="en">


<head>
  <meta charset="utf-8" />
    
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
  <title>
    vscode+hexo构建本地静态网站 |  杂货铺子
  </title>
  <meta name="generator" content="hexo-theme-yilia-plus">
  
  <link rel="shortcut icon" href="/hexo_blog_test/favicon.ico" />
  
  
<link rel="stylesheet" href="/hexo_blog_test/dist/main.css">

  
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Shen-Yu/cdn/css/remixicon.min.css">

  
<link rel="stylesheet" href="/hexo_blog_test/css/custom.css">

  
  
<script src="https://cdn.jsdelivr.net/npm/pace-js@1.0.2/pace.min.js"></script>

  
  

  

<link rel="alternate" href="/hexo_blog_test/hexo_blog_test/atom.xml" title="杂货铺子" type="application/atom+xml">
</head>

</html>

<body>
  <div id="app">
    <main class="content on">
      <section class="outer">
  <article id="post-study/vscode+hexo构建本地静态网站" class="article article-type-post" itemscope
  itemprop="blogPost" data-scroll-reveal>

  <div class="article-inner">
    
    <header class="article-header">
       
<h1 class="article-title sea-center" style="border-left:0" itemprop="name">
  vscode+hexo构建本地静态网站
</h1>
 

    </header>
    

    
    <div class="article-meta">
      <a href="/hexo_blog_test/study/vscode+hexo%E6%9E%84%E5%BB%BA%E6%9C%AC%E5%9C%B0%E9%9D%99%E6%80%81%E7%BD%91%E7%AB%99/" class="article-date">
  <time datetime="2020-04-23T15:58:01.332Z" itemprop="datePublished">2020-04-23</time>
</a>
      
  <div class="article-category">
    <a class="article-category-link" href="/hexo_blog_test/categories/IT/">IT</a> / <a class="article-category-link" href="/hexo_blog_test/categories/IT/vscode/">vscode</a> / <a class="article-category-link" href="/hexo_blog_test/categories/IT/vscode/hexo/">hexo</a>
  </div>

      
      
<div class="word_count">
    <span class="post-time">
        <span class="post-meta-item-icon">
            <i class="ri-quill-pen-line"></i>
            <span class="post-meta-item-text"> Word count:</span>
            <span class="post-count">1.6k</span>
        </span>
    </span>

    <span class="post-time">
        &nbsp; | &nbsp;
        <span class="post-meta-item-icon">
            <i class="ri-book-open-line"></i>
            <span class="post-meta-item-text"> Reading time≈</span>
            <span class="post-count">6 min</span>
        </span>
    </span>
</div>

      
    </div>
    

    
    
    <div class="tocbot"></div>





    

    
    <div class="article-entry" itemprop="articleBody">
      
      

      
      <h2 id="准备程序"><a href="#准备程序" class="headerlink" title="准备程序"></a>准备程序</h2><ul>
<li>下载并安装vscode</li>
<li>下载并安装node.js</li>
<li>下载并安装Git<br> 配置Git：<br> cmd中：<code>git config --global user.name &quot;你的名字&quot;</code><br> <code>git config --global 你的邮箱</code></li>
</ul>
<h2 id="安装hexo"><a href="#安装hexo" class="headerlink" title="安装hexo"></a>安装hexo</h2><p><a href="https://hexo.io/zh-cn/docs/index.html" target="_blank" rel="noopener">hexo文档</a></p>
<ul>
<li>使用<code>node -v</code>查看nodejs是否满足hexo的版本要求。</li>
<li>调整npm的源为淘宝源：<code>npm config set registry https://registry.npm.taobao.org</code>。</li>
<li>安装hexo：<code>npm install -g hexo-cli</code>。</li>
</ul>
<a id="more"></a>

<h2 id="初始化hexo"><a href="#初始化hexo" class="headerlink" title="初始化hexo"></a>初始化hexo</h2><ul>
<li><p>管理员权限启动cmd。</p>
</li>
<li><p>找个位置放置blog，例如F盘：<code>f:</code>。</p>
</li>
<li><p>新建个目录作为hexo博客的所在目录。例：<code>mkdir hexo_blog</code>。</p>
</li>
<li><p>初始化blog目录:<code>hexo init hexo_blog</code>。</p>
</li>
<li><p>进入blog目录，以后的hexo相关操作均在该目录进行。<code>cd hexo_blog</code>。<br>  初始化后的目录结构：</p>
<pre><code>.
├── _config.yml
├── package.json
├── scaffolds
├── source
|   ├── _drafts
|   └── _posts
└── themes</code></pre><p>  需要操作的文件和目录：<code>_config.yml</code>，<code>themes</code>，<code>_posts</code>，后期还会生成<code>public</code>。<br>  <a href="https://hexo.io/zh-cn/docs/setup" target="_blank" rel="noopener">目录用途参考</a></p>
</li>
</ul>
<h2 id="调整实际文章的存放位置"><a href="#调整实际文章的存放位置" class="headerlink" title="调整实际文章的存放位置"></a>调整实际文章的存放位置</h2><p>虽然在此时就可以使用<code>hexo n xx.md</code>在上述的<code>_posts</code>文件夹中创建文章了（直接在<code>_posts</code>文件夹新建文件也是可以的，区别在于自动新建的可以有模板结构，当然，手动新建直接复制对应的模板也是一样的），但是个人需求要有不止一个文章源，不同文章源会推送到不同的blog，例如“study”里的文章推送到公网，“work”里的文章推送到工作服务器。由于使用vscode对文章进行编辑，所以希望不同的文章源能放在同一个其他位置的目录，在vscode中以工作区的形式打开，所以选择在其他位置创建文章源存放的目录，所有文章放在一起管理，然后通过软链接的形式将对应的文件夹和对应的hexo实例里的<code>_posts</code>关联。例：<br><code>mklink /d &quot;初始化好的公网hexo文件夹\source\_posts\study&quot; &quot;真实文章存放位置\study&quot;</code><br><code>mklink /d &quot;初始化好的工作hexo文件夹\source\_posts\work&quot; &quot;真实文章存放位置\work&quot;</code><br>之后写文章都从真实存放位置进入进行编辑，<strong>手动创建文章，并同时在同目录下手动创建和文章同名的文件夹放置资源文件</strong>。</p>
<h2 id="调整hexo-blog的配置"><a href="#调整hexo-blog的配置" class="headerlink" title="调整hexo_blog的配置"></a>调整<code>hexo_blog</code>的配置</h2><p><code>hexo_blog</code>下的<code>_config.yml</code>为整站配置文件。<br><a href="https://hexo.io/zh-cn/docs/configuration" target="_blank" rel="noopener">配置参考</a><br>修改时注意冒号后的空格不能省略。<br>根据上步中的目标，修改如下配置；</p>
<ul>
<li><code>permalink: :title/</code> # 在文章源中会手动创建目录结构，不需要自动按照时间生成。</li>
<li><code>post_asset_folder: true</code> # 创建同名文件夹存放资源文件</li>
</ul>
<p>安装<code>hexo-asset-image</code>解决图片引用的问题：<code>npm install https://github.com/CodeFalling/hexo-asset-image --save</code></p>
<h2 id="调整vscode"><a href="#调整vscode" class="headerlink" title="调整vscode"></a>调整vscode</h2><h3 id="安装markdown相关扩展"><a href="#安装markdown相关扩展" class="headerlink" title="安装markdown相关扩展"></a>安装markdown相关扩展</h3><ul>
<li>Markdown All in One # 各种方便的markdown功能</li>
<li>Markdown Preview Enhanced # 右键菜单的markdown文档预览</li>
<li>Paste Image # 方便将剪贴板的图片存放到本地特定位置并插入markdown</li>
</ul>
<h3 id="创建工作区并进行配置"><a href="#创建工作区并进行配置" class="headerlink" title="创建工作区并进行配置"></a>创建工作区并进行配置</h3><p>打开blog编写目录，<code>文件</code>→<code>将工作区另存为</code>保存工作区。<br><code>设置</code>→<code>工作区</code>标签→搜索<code>Paste Image</code>→调整<code>Paste Image:Path</code>为<code>${currentFileDir}/${currentFileNameWithoutExt}</code>，保存，这样在<code>Alt+Ctrl+V</code>插入剪贴板图片时，图片会保存到同目录下的同名文件夹中并被插入markdown文件。</p>
<h2 id="写写写"><a href="#写写写" class="headerlink" title="写写写"></a>写写写</h2><ul>
<li>不了解文档结构可以打开<code>_posts</code>文件夹中示例文件看下。</li>
<li>在源地址创建<code>xx.md</code>，在同级目录下创建<code>xx</code>目录。</li>
<li>打开文章，编辑<a href="https://hexo.io/zh-cn/docs/front-matter" target="_blank" rel="noopener">Front-matter</a>。几个比较重要的：<ul>
<li>title</li>
<li>tags</li>
<li>categories # 注意同级categories的使用形式。</li>
</ul>
</li>
<li>写写写。</li>
<li>插入图片：把图片放到<code>xx</code>目录，在<code>xx.md</code>中引用。</li>
<li>粘贴图片：<code>ctrl+c</code>复制，在<code>xx.md</code>中<code>ctrl+alt+v</code>复制。</li>
</ul>
<h2 id="本地预览"><a href="#本地预览" class="headerlink" title="本地预览"></a>本地预览</h2><p>在<code>hexo_blog</code>下运行<code>hexo g</code>，在<code>http://localhost:4000/</code>中预览。</p>
<h2 id="安装主题"><a href="#安装主题" class="headerlink" title="安装主题"></a>安装主题</h2><p>可以在<a href="https://hexo.io/themes/" target="_blank" rel="noopener">这里</a>挑选中意的主题。<br>以安装<code>ayer</code>主题为例，<a href="https://shen-yu.gitee.io/2019/ayer/" target="_blank" rel="noopener">中文说明</a>。</p>
<h3 id="拉取主题"><a href="#拉取主题" class="headerlink" title="拉取主题"></a>拉取主题</h3><p>在<code>hexo_blog</code>下运行<code>git clone https://gitee.com/shen-yu/hexo-theme-ayer.git themes/ayer</code></p>
<h3 id="修改blog配置文件（在hexo-blog下的-config-yml）"><a href="#修改blog配置文件（在hexo-blog下的-config-yml）" class="headerlink" title="修改blog配置文件（在hexo_blog下的_config.yml）"></a>修改blog配置文件（在<code>hexo_blog</code>下的<code>_config.yml</code>）</h3><p><code>theme: ayer</code></p>
<h3 id="按需调整主题配置文件（在hexo-blog-theme-ayer下的-config-yml）"><a href="#按需调整主题配置文件（在hexo-blog-theme-ayer下的-config-yml）" class="headerlink" title="按需调整主题配置文件（在hexo_blog/theme/ayer下的_config.yml）"></a>按需调整主题配置文件（在<code>hexo_blog/theme/ayer</code>下的<code>_config.yml</code>）</h3><p>按需调整，所有内容都有备注。</p>
<h3 id="安装和配置插件"><a href="#安装和配置插件" class="headerlink" title="安装和配置插件"></a>安装和配置插件</h3><h4 id="搜索插件"><a href="#搜索插件" class="headerlink" title="搜索插件"></a>搜索插件</h4><ul>
<li><p><code>npm install hexo-generator-searchdb --save</code></p>
</li>
<li><p>修改或增加blog配置文件（在<code>hexo_blog</code>下的<code>_config.yml</code>）,注意冒号后的空格。</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># hexo-generator-searchdb</span></span><br><span class="line">  <span class="attr">search:</span></span><br><span class="line">  <span class="attr">path:</span> <span class="string">search.xml</span></span><br><span class="line">  <span class="attr">field:</span> <span class="string">post</span></span><br><span class="line">  <span class="attr">format:</span> <span class="string">html</span></span><br></pre></td></tr></table></figure>

</li>
</ul>
<h4 id="rss插件"><a href="#rss插件" class="headerlink" title="rss插件"></a>rss插件</h4><ul>
<li><code>npm install hexo-generator-feed --save</code></li>
<li>修改或增加blog配置文件（在<code>hexo_blog</code>下的<code>_config.yml</code>）,注意冒号后的空格。<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">feed:</span></span><br><span class="line">  <span class="attr">type:</span> <span class="string">atom</span></span><br><span class="line">  <span class="attr">path:</span> <span class="string">atom.xml</span></span><br><span class="line">  <span class="attr">limit:</span> <span class="number">20</span></span><br><span class="line">  <span class="attr">hub:</span></span><br><span class="line">  <span class="attr">content:</span></span><br><span class="line">  <span class="attr">content_limit:</span> <span class="number">140</span></span><br><span class="line">  <span class="attr">content_limit_delim:</span> <span class="string">' '</span></span><br><span class="line">  <span class="attr">order_by:</span> <span class="string">-date</span></span><br></pre></td></tr></table></figure>
<h4 id="分类页面"><a href="#分类页面" class="headerlink" title="分类页面"></a>分类页面</h4></li>
<li><code>hexo new page categories</code></li>
<li>然后将以下复制到/source/categories/index.md文件<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">---</span></span><br><span class="line"><span class="attr">title:</span> <span class="string">categories</span></span><br><span class="line"><span class="attr">type:</span> <span class="string">"categories"</span></span><br><span class="line"><span class="attr">layout:</span> <span class="string">"categories"</span></span><br><span class="line"><span class="meta">---</span></span><br></pre></td></tr></table></figure>

</li>
</ul>
<h4 id="标签页面"><a href="#标签页面" class="headerlink" title="标签页面"></a>标签页面</h4><ul>
<li><code>hexo new page tags</code></li>
<li>然后将以下复制到/source/tags/index.md文件<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">---</span></span><br><span class="line"><span class="attr">title:</span> <span class="string">tags</span></span><br><span class="line"><span class="attr">type:</span> <span class="string">"tags"</span></span><br><span class="line"><span class="attr">layout:</span> <span class="string">"tags"</span></span><br><span class="line"><span class="meta">---</span></span><br></pre></td></tr></table></figure>

</li>
</ul>
<h2 id="部署"><a href="#部署" class="headerlink" title="部署"></a>部署</h2><p><a href="https://hexo.io/zh-cn/docs/one-command-deployment" target="_blank" rel="noopener">各种各样的部署方案</a></p>
<h3 id="使用Git部署到码云"><a href="#使用Git部署到码云" class="headerlink" title="使用Git部署到码云"></a>使用Git部署到码云</h3><ul>
<li>在码云上新建空仓库，获得仓库的地址。</li>
<li></li>
<li>安装Git一键部署插件：<code>npm install hexo-deployer-git --save</code></li>
<li>修改blog配置文件（在<code>hexo_blog</code>下的<code>_config.yml</code>）  <figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">deploy:</span></span><br><span class="line">    <span class="attr">type:</span> <span class="string">git</span></span><br><span class="line">    <span class="attr">repo:</span> <span class="string">仓库的地址</span></span><br><span class="line">    <span class="attr">branch:</span> <span class="string">master</span></span><br><span class="line">    <span class="attr">message:</span> <span class="string">blog</span> <span class="string">update</span></span><br></pre></td></tr></table></figure></li>
<li>一键部署：<code>hexo deploy</code>，中间需要输入码云的用户名密码</li>
<li>开启仓库的<code>Pages</code>服务（需要绑定手机）：在仓库的管理界面：<code>服务</code>里的<code>Gitee Pages</code>，开启完成后会获得一个Pages的地址。</li>
<li>修改blog配置文件（在hexo_blog下的_config.yml）  <figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">url:</span> <span class="string">你的Pages地址</span> <span class="comment">#大概这样 http://用户名.gitee.io</span></span><br><span class="line"><span class="attr">root:</span> <span class="string">/你的仓库名/</span></span><br></pre></td></tr></table></figure></li>
<li>修改主题的资源文件路径<ul>
<li>蛋疼的问题 主题的资源文件<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">favicon:</span> <span class="string">/你的仓库名/favicon.ico</span></span><br><span class="line"><span class="attr">logo:</span> <span class="string">/你的仓库名/images/ayer-side.svg</span></span><br><span class="line"><span class="attr">cover:</span></span><br><span class="line">    <span class="attr">enable:</span> <span class="literal">true</span></span><br><span class="line">    <span class="attr">path:</span> <span class="string">/你的仓库名/images/cover1.jpg</span> <span class="comment"># /source/images目录下附送多张美图，可更换</span></span><br><span class="line">    <span class="attr">logo:</span> <span class="literal">false</span> <span class="comment">#/images/ayer.svg，如果不要直接设置成false</span></span><br></pre></td></tr></table></figure></li>
<li>蛋疼的问题 主题使用相关插件的引用问题<br>主题中引用的js脚本不会被转化，所以只能手工修改有问题的引用。<br>因为二级域名的问题，默认的主题无法正常加载到<code>search.js</code>,需要手工修正（配套的还有<code>search.xml</code>）。<br>在主题文件中搜索<code>search.js</code>,定位到引用位置为<code>themes/ayer/source/dist/main.js</code>,将<code>search.js</code>的引用路径修改为<code>/仓库名/js/search.js</code>,将<code>search.xml</code>的引用路径修改为<code>/仓库名/仓库名/search.xml</code></li>
</ul>
</li>
<li>再次部署：<code>hexo generate --deploy</code>or<code>hexo cl &amp;&amp; hexo g &amp;&amp; hexo d</code></li>
<li>在Pages管理页面点击更新按钮，自动部署是付费功能。<code>ctrl+F5</code>刷新看效果。</li>
</ul>

      
      <!-- reward -->
      
    </div>
    
    
      <!-- copyright -->
      
    <footer class="article-footer">
      
          
<div class="share-btn">
      <span class="share-sns share-outer">
        <i class="ri-share-forward-line"></i>
        分享
      </span>
      <div class="share-wrap">
        <i class="arrow"></i>
        <div class="share-icons">
          
          <a class="weibo share-sns" href="javascript:;" data-type="weibo">
            <i class="ri-weibo-fill"></i>
          </a>
          <a class="weixin share-sns wxFab" href="javascript:;" data-type="weixin">
            <i class="ri-wechat-fill"></i>
          </a>
          <a class="qq share-sns" href="javascript:;" data-type="qq">
            <i class="ri-qq-fill"></i>
          </a>
          <a class="douban share-sns" href="javascript:;" data-type="douban">
            <i class="ri-douban-line"></i>
          </a>
          <!-- <a class="qzone share-sns" href="javascript:;" data-type="qzone">
            <i class="icon icon-qzone"></i>
          </a> -->
          
          <a class="facebook share-sns" href="javascript:;" data-type="facebook">
            <i class="ri-facebook-circle-fill"></i>
          </a>
          <a class="twitter share-sns" href="javascript:;" data-type="twitter">
            <i class="ri-twitter-fill"></i>
          </a>
          <a class="google share-sns" href="javascript:;" data-type="google">
            <i class="ri-google-fill"></i>
          </a>
        </div>
      </div>
</div>

<div class="wx-share-modal">
    <a class="modal-close" href="javascript:;"><i class="ri-close-circle-line"></i></a>
    <p>扫一扫，分享到微信</p>
    <div class="wx-qrcode">
      <img src="//api.qrserver.com/v1/create-qr-code/?size=150x150&data=http://flow12.gitee.io/study/vscode+hexo%E6%9E%84%E5%BB%BA%E6%9C%AC%E5%9C%B0%E9%9D%99%E6%80%81%E7%BD%91%E7%AB%99/" alt="微信分享二维码">
    </div>
</div>

<div id="share-mask"></div>
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/hexo_blog_test/tags/hexo/" rel="tag">hexo</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/hexo_blog_test/tags/vscode/" rel="tag">vscode</a></li></ul>


    </footer>

  </div>

  
  
  <nav class="article-nav">
    
    
      <a href="/hexo_blog_test/study/vscode%E6%9B%BF%E6%8D%A2%E5%8F%98%E9%87%8F/" class="article-nav-link">
        <strong class="article-nav-caption">下一篇</strong>
        <div class="article-nav-title">vscode内置替换变量</div>
      </a>
    
  </nav>


  

  

  
  
  
  
  

</article>
</section>
      <footer class="footer">
  <div class="outer">
    <ul>
      <li>
        Copyrights &copy;
        2020
        <i class="ri-heart-fill heart_icon"></i> flow12
      </li>
    </ul>
    <ul>
      <li>
        
        
        
        Powered by <a href="https://hexo.io" target="_blank">Hexo</a>
        <span class="division">|</span>
        Theme - <a href="https://github.com/Shen-Yu/hexo-theme-ayer" target="_blank">Ayer</a>
        
      </li>
    </ul>
    <ul>
      <li>
        
      </li>
    </ul>
    <ul>
      
    </ul>
    <ul>
      <li>
        <!-- cnzz统计 -->
        
      </li>
    </ul>
  </div>
</footer>
      <div class="float_btns">
        <div class="totop" id="totop">
  <i class="ri-arrow-up-line"></i>
</div>

<div class="todark" id="todark">
  <i class="ri-moon-line"></i>
</div>

      </div>
    </main>
    <aside class="sidebar on">
      <button class="navbar-toggle"></button>
<nav class="navbar">
  
  <div class="logo">
    <a href="/hexo_blog_test/"><img src="/hexo_blog_test/images/ayer-side.svg" alt="杂货铺子"></a>
  </div>
  
  <ul class="nav nav-main">
    
    <li class="nav-item">
      <a class="nav-item-link" href="/hexo_blog_test/">主页</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/hexo_blog_test/archives">归档</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/hexo_blog_test/categories">分类</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/hexo_blog_test/tags">标签</a>
    </li>
    
    <li class="nav-item">
      <a class="nav-item-link" href="/hexo_blog_test/tags/video/">视频</a>
    </li>
    
  </ul>
</nav>
<nav class="navbar navbar-bottom">
  <ul class="nav">
    <li class="nav-item">
      
      <a class="nav-item-link nav-item-search"  title="Search">
        <i class="ri-search-line"></i>
      </a>
      
      
      <a class="nav-item-link" target="_blank" href="/hexo_blog_test/atom.xml" title="RSS Feed">
        <i class="ri-rss-line"></i>
      </a>
      
    </li>
  </ul>
</nav>
<div class="search-form-wrap">
  <div class="local-search local-search-plugin">
  <input type="search" id="local-search-input" class="local-search-input" placeholder="Search...">
  <div id="local-search-result" class="local-search-result"></div>
</div>
</div>
    </aside>
    <script>
      if (window.matchMedia("(max-width: 768px)").matches) {
        document.querySelector('.content').classList.remove('on');
        document.querySelector('.sidebar').classList.remove('on');
      }
    </script>
    <div id="mask"></div>

<!-- #reward -->
<div id="reward">
  <span class="close"><i class="ri-close-line"></i></span>
  <p class="reward-p"><i class="ri-cup-line"></i>请我喝杯咖啡吧~</p>
  <div class="reward-box">
    
    <div class="reward-item">
      <img class="reward-img" src="https://cdn.jsdelivr.net/gh/Shen-Yu/cdn/img/alipay.jpg">
      <span class="reward-type">支付宝</span>
    </div>
    
    
    <div class="reward-item">
      <img class="reward-img" src="https://cdn.jsdelivr.net/gh/Shen-Yu/cdn/img/wechat.jpg">
      <span class="reward-type">微信</span>
    </div>
    
  </div>
</div>
    
<script src="/hexo_blog_test/js/jquery-2.0.3.min.js"></script>


<script src="/hexo_blog_test/js/lazyload.min.js"></script>


<script>
  try {
    var typed = new Typed("#subtitle", {
      strings: ['面朝大海，春暖花开', '愿你一生努力，一生被爱', '想要的都拥有，得不到的都释怀'],
      startDelay: 0,
      typeSpeed: 200,
      loop: true,
      backSpeed: 100,
      showCursor: true
    });
  } catch (err) {
  }

</script>




<script src="/hexo_blog_test/js/tocbot.min.js"></script>

<script>
  // Tocbot_v4.7.0  http://tscanlin.github.io/tocbot/
  tocbot.init({
    tocSelector: '.tocbot',
    contentSelector: '.article-entry',
    headingSelector: 'h1, h2, h3, h4, h5, h6',
    hasInnerContainers: true,
    scrollSmooth: true,
    scrollContainer: 'main',
    positionFixedSelector: '.tocbot',
    positionFixedClass: 'is-position-fixed',
    fixedSidebarOffset: 'auto'
  });
</script>



<script src="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jquery-modal@0.9.2/jquery.modal.min.css">
<script src="https://cdn.jsdelivr.net/npm/justifiedGallery@3.7.0/dist/js/jquery.justifiedGallery.min.js"></script>

<script src="/hexo_blog_test/dist/main.js"></script>



<!-- Root element of PhotoSwipe. Must have class pswp. -->
<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

    <!-- Background of PhotoSwipe. 
         It's a separate element as animating opacity is faster than rgba(). -->
    <div class="pswp__bg"></div>

    <!-- Slides wrapper with overflow:hidden. -->
    <div class="pswp__scroll-wrap">

        <!-- Container that holds slides. 
            PhotoSwipe keeps only 3 of them in the DOM to save memory.
            Don't modify these 3 pswp__item elements, data is added later on. -->
        <div class="pswp__container">
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
            <div class="pswp__item"></div>
        </div>

        <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
        <div class="pswp__ui pswp__ui--hidden">

            <div class="pswp__top-bar">

                <!--  Controls are self-explanatory. Order can be changed. -->

                <div class="pswp__counter"></div>

                <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>

                <button class="pswp__button pswp__button--share" style="display:none" title="Share"></button>

                <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>

                <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>

                <!-- Preloader demo http://codepen.io/dimsemenov/pen/yyBWoR -->
                <!-- element will get class pswp__preloader--active when preloader is running -->
                <div class="pswp__preloader">
                    <div class="pswp__preloader__icn">
                        <div class="pswp__preloader__cut">
                            <div class="pswp__preloader__donut"></div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                <div class="pswp__share-tooltip"></div>
            </div>

            <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
            </button>

            <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
            </button>

            <div class="pswp__caption">
                <div class="pswp__caption__center"></div>
            </div>

        </div>

    </div>

</div>

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/default-skin/default-skin.min.css">
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/photoswipe@4.1.3/dist/photoswipe-ui-default.min.js"></script>

<script>
    function viewer_init() {
        let pswpElement = document.querySelectorAll('.pswp')[0];
        let $imgArr = document.querySelectorAll(('.article-entry img:not(.reward-img)'))

        $imgArr.forEach(($em, i) => {
            $em.onclick = () => {
                // slider展开状态
                // todo: 这样不好，后面改成状态
                if (document.querySelector('.left-col.show')) return
                let items = []
                $imgArr.forEach(($em2, i2) => {
                    let img = $em2.getAttribute('data-idx', i2)
                    let src = $em2.getAttribute('data-target') || $em2.getAttribute('src')
                    let title = $em2.getAttribute('alt')
                    // 获得原图尺寸
                    const image = new Image()
                    image.src = src
                    items.push({
                        src: src,
                        w: image.width || $em2.width,
                        h: image.height || $em2.height,
                        title: title
                    })
                })
                var gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, {
                    index: parseInt(i)
                });
                gallery.init()
            }
        })
    }
    viewer_init()
</script>


<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
      tex2jax: {
          inlineMath: [ ['$','$'], ["\\(","\\)"]  ],
          processEscapes: true,
          skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code']
      }
  });

  MathJax.Hub.Queue(function() {
      var all = MathJax.Hub.getAllJax(), i;
      for(i=0; i < all.length; i += 1) {
          all[i].SourceElement().parentNode.className += ' has-jax';
      }
  });
</script>

<script src="https://cdn.jsdelivr.net/npm/mathjax@2.7.6/unpacked/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script>
  var ayerConfig = {
    mathjax: true
  }
</script>




<script type="text/javascript" src="https://js.users.51.la/20544303.js"></script>


<!-- 复制 -->

  
<link rel="stylesheet" href="/hexo_blog_test/css/clipboard.css">

  <script src="https://cdn.jsdelivr.net/npm/clipboard@2/dist/clipboard.min.js"></script>
<script>
  function wait(callback, seconds) {
    var timelag = null;
    timelag = window.setTimeout(callback, seconds);
  }
  !function (e, t, a) {
    var initCopyCode = function(){
      var copyHtml = '';
      copyHtml += '<button class="btn-copy" data-clipboard-snippet="">';
      copyHtml += '<i class="ri-file-copy-2-line"></i><span>COPY</span>';
      copyHtml += '</button>';
      $(".highlight .code pre").before(copyHtml);
      $(".article pre code").before(copyHtml);
      var clipboard = new ClipboardJS('.btn-copy', {
        target: function(trigger) {
          return trigger.nextElementSibling;
        }
      });
      clipboard.on('success', function(e) {
        let $btn = $(e.trigger);
        $btn.addClass('copied');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-checkbox-circle-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPIED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-checkbox-circle-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
      clipboard.on('error', function(e) {
        e.clearSelection();
        let $btn = $(e.trigger);
        $btn.addClass('copy-failed');
        let $icon = $($btn.find('i'));
        $icon.removeClass('ri-file-copy-2-line');
        $icon.addClass('ri-time-line');
        let $span = $($btn.find('span'));
        $span[0].innerText = 'COPY FAILED';
        
        wait(function () { // 等待两秒钟后恢复
          $icon.removeClass('ri-time-line');
          $icon.addClass('ri-file-copy-2-line');
          $span[0].innerText = 'COPY';
        }, 2000);
      });
    }
    initCopyCode();
  }(window, document);
</script>




    
  </div>
</body>

</html>